/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-04-16 13:39:10
 * @LastEditTime : 2023-07-21 08:36:10
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Pages\Admin\Assembly\HeadList.jsx
 * @Description  :
 */
import { HeaderOptionList } from '../../../Common/Router/MenuNav/DiyList/Theme/HeaderOptions'
import { HeaderUserInfo } from '../../../Common/Router/MenuNav/DiyList/Theme/HeaderUserInfo'
import { ModalBox } from '../../../Common/Modal/ModalBox'
import { useState } from 'react'

import { project } from '../../../Common/Data'
import { useEventEmitter, useRequest, useSetState } from 'ahooks'
import { Http } from '../../../Common/Api'
import { useEffect } from 'react'

const { hostname } = window.location
const { imageUrl, title } = project[hostname]
export const Head001 = ({ data, SelectMenusEvent }) => {
    const { heading, subtitleStatus, subtitle, HeaderOptionsSet, HeaderUserInfoSet } = data
    const [OptionsCall, setOptionsCall] = useState()
    const OptionsEvent = useEventEmitter()
    OptionsEvent.useSubscription(val => setOptionsCall(val))
    const [parameter, setParameter] = useSetState({})
    const { runAsync: getFormGetStatusStatistics } = useRequest(Http, { manual: true })
    useEffect(() => {
        if (hostname === 'heyi.ljkjkf.com') {
            getFormGetStatusStatistics({ url: 'getFormGetStatusStatistics' }).then(res => {
                const { pending, unRead } = res
                setParameter({ '004': Number(pending) + Number(unRead) })
            })
        }
    }, [getFormGetStatusStatistics, setParameter])

    return (
        <div className="Head001">
            <div className="Left">
                <img src={imageUrl + 'Logo.png'} alt="" />
                <div>
                    <div>{heading || title}</div>
                    {subtitleStatus && <div>{subtitle}</div>}
                </div>
            </div>

            <div className="Right">
                <HeaderOptionList data={HeaderOptionsSet} parameter={parameter} SelectMenusEvent={SelectMenusEvent} />
                <HeaderUserInfo data={HeaderUserInfoSet} OptionsEvent={OptionsEvent} />
                <ModalBox OptionsCall={OptionsCall} />
            </div>
        </div>
    )
}
